
""""添加知识页面基类"""

from pages.base_page import BasePage
from selenium.webdriver.common.by import By

class NewKnowledgePage(BasePage):

     url = 'crm/index.php?m=knowledge&a=add'
     #定位器
     # 知识标题
     zhishi_title_locator = (By.ID, 'title')
     # 知识分类
     category_locator = ( By.CSS_SELECTOR, 'body > div.container > div.row > div > form > table > tbody > tr:nth-child(3) > td.tdleft')
     #选择第一个
     first_category_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tbody > tr:nth-child(3) > td:nth-child(2) > select > option:nth-child(1)')
     #切换iframe
     iframe_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tbody > tr:nth-child(4) > td:nth-child(2) > div > div.ke-edit > iframe')
     # 内容
     zhishi_neirong_locator = (By.CSS_SELECTOR, 'body')
     # 保存
     save_submit_locator = (By.CSS_SELECTOR, 'body > div.container > div.row > div > form > table > tfoot > tr > td > input:nth-child(1)')
     #返回
     return_submit_locator=(By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tfoot > tr > td > input:nth-child(3)')




     #输入知识标题
     def input_add_knowledge_title(self,knowledge_name):
         self.driver.find_element(*self.zhishi_title_locator).send_keys(knowledge_name)

     #选择知识分类
     def click_add_knowledge_category(self):
        self.driver.find_element(*self.category_locator).click()
     #选择第一个
     def click_add_category_first(self):
         self.driver.find_element(*self.first_category_locator).click()
     #切换iframe
     def switch_to_knowledge_content_iframe(self):
         iframe = self.driver.find_element(*self.iframe_locator)
         self.driver.switch_to.frame(iframe)
     #输入知识内容
     def input_add_knowledge_neirong(self,knowledge_neirong):
         self.driver.find_element(*self.zhishi_neirong_locator).send_keys(knowledge_neirong)
     #点击保存
     def click_add_knowledge_save(self):
         self.driver.find_element(*self.save_submit_locator).click()
     #点击返回
     def click_add_knowledge_return(self):
         self.driver.find_element(*self.return_submit_locator)


